!pr2
!lm12
!rm75
Search for Page-Zero References.........Bob Sander-Cederlof

Many times I have wanted a utility which would list out all references to page-zero locations withing a program.  For example, when I am trying to avoid conflicts with DOS or Applesoft, I need to know which ones they use and where.

The following little program hooks into the Apple Monitor through the control-Y user command.  You type in the address range you want to search through, control-Y, and a carriage return.  The Apple will disassemble only those instructions within the address range which reference page-zero locations.

Lines 1220-1280 set up the control-Y vector.  When the monitor detects a control-Y command, it branches to $3F8.  The JMP instruction there in turn branches to CTRL.Y at line 1320.

Line 1330 loads the first address of the range into PCL and PCH.  If you did not type any range before the control-Y, the previous value will be used.

Lines 1340-1540 decide whether the instruction starting at the address in PCL,PCH references page-zero or not.  All instructions which reference page-zero have opcodes of the form x1, x4, x5, or x6.  All of the x1, x5, and x6 possiblities are valid; only 24, 84-C4, and E4 in the x4 column are valid.

Lines 1580 and 1590 call on a piece of the monitor L-command to disassemble the one instruction.  This also updates PCL,PCH to point to the next opcode byte.

Lines 1600-1700 allow you to stop/start the listing by typing any key, to single-step the listing by pressing any two keys simultaneously, and to abort by typing RETURN.

Lines 1740-1780 are executed if the instruction does not reference page-zero.  The call on pieces of the L-command to figure out the number of bytes in the instruction and update PCL,PCH accordingly.

Lines 1820-1870 check to see if the range you specified has been covered yet.  If not, keep searching; if so, stop.

This kind of program should be in your tool-kit when you are debugging.  Just don't lose it under all those other tools!
